package com.shopping_assistant.model;

import java.util.List;
import android.location.Location;

public class Shop {
	
	private Location location;

	private String name;
	
	private ShopType shopType;

	private String address;

	private String open;

	private String close;

	private String phone;

	private String description;
	
	private String homepage;
	
	private List<Offer> currentOffers;
	
	public Shop(String name, ShopType shopType, String address, String open, String close, String phone, String description, String homepage, List<Offer> currentOffers, double latitude, double longitude) {
		super();
		this.name = name;
		this.shopType = shopType;
		this.address = address;
		this.open = open;
		this.close = close;
		this.phone = phone;
		this.description = description;
		this.homepage = homepage;
		this.currentOffers = currentOffers;
		
		location = new Location("SHOP: " + name);
		location.setLatitude(latitude);
		location.setLongitude(longitude);
		
	}
	
	public double getLatitude(){
		return location.getLatitude();
	}
	
	public double getLongitude() {
		return location.getLongitude();
	}
	
	public Location getLocation() {
		return location;
	}

	public void setLocation(Location location) {
		this.location = location;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getOpen() {
		return open;
	}

	public void setOpen(String open) {
		this.open = open;
	}

	public String getClose() {
		return close;
	}

	public void setClose(String close) {
		this.close = close;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getHomepage() {
		return homepage;
	}

	public void setHomepage(String homepage) {
		this.homepage = homepage;
	}
	
	public List<Offer> getCurrentOffers() {
		return currentOffers;
	}
	
	public ShopType getShopType(){
		return shopType;
	}
	
	@Override
	public String toString() {
		return String.format("Name: %s, Location: %s", name, location.toString());
	}

	public double distanceTo(Location lastLocation) {
		
		float[] result = new float[1];
		
		Location.distanceBetween(lastLocation.getLatitude(), lastLocation.getLongitude(), location.getLatitude(), location.getLongitude(), result);
		
		return (double) result[0];
	}
}
